<?php echo $this->Session->flash(); ?>
<h1>ANEXOS</h1>
<div id="loading" style="display: none;">
    <?php echo $html->image('loading.gif', array('border' => "0", 'align' => 'center')); ?>
</div>
<table id="tabla">
    <thead>
        <tr>
            <th>Anexo</th>
            <th>Magnitud</th>
            <th>Valor</th>
            <th>Descripción</th>
            <th colspan="2"></th>
        </tr>
    </thead>
    <tbody>
        <?php
        $i = 1;
        $valorTotal = 0;
        foreach ($annexes as $annex):
            $valorTotal += ($annex['EvaluationAnnex']['magnitud'] * $annex['EvaluationAnnex']['valor_unitario']);
            ?>
            <tr>
                <td><?php echo "Anexo " . $i ?></td>  
                <td><?php echo number_format($annex['EvaluationAnnex']['magnitud'], 2, ',', '.') ?></td>
                <td><?php echo "$ " . number_format(($annex['EvaluationAnnex']['magnitud'] * $annex['EvaluationAnnex']['valor_unitario']), 2, ',', '.') ?></td>
                <td><?php
        echo $annex['EvaluationAnnex']['descripcion'];
        $i++;
            ?></td>
                <td>                
                    <?php if($this->Session->read('estado') == 0 AND $evaluacion['EvaluationAppraisal']['cerrado']==0) echo $ajax->link('Editar', array('controller' => 'EvaluationAnnexes', 'action' => 'edit', $annex['EvaluationAnnex']['id']), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?>
                </td>
                <td>
                    <?php if($this->Session->read('estado') == 0 AND $evaluacion['EvaluationAppraisal']['cerrado']==0) echo $ajax->link('Eliminar', array('controller' => 'EvaluationAnnexes', 'action' => 'delete', $annex['EvaluationAnnex']['id'], $evaluation_appraisal_id), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false), '¿Realmente desea borrar el registro?'); ?>     
                </td>
            </tr>
        <?php endforeach; ?>
        <tr>
            <td></td>
            <td><b>Valor total</b></td>
            <td><b><?php echo '$' . number_format($valorTotal, 2, ',', '.') ?></b></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>
<br>
<?php if($this->Session->read('estado') == 0 AND $evaluacion['EvaluationAppraisal']['cerrado']==0) echo $ajax->link('Adicionar', array('controller' => 'EvaluationAnnexes', 'action' => 'add', $evaluation_appraisal_id), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?>
<br>
<br>
<br>
<br>
<?php
echo $ajax->link($html->image('regresar.gif', array('width' => '30', 'heigth' => '30', 'alt' => 'Regresar', 'title' => 'regresar')), array('controller' => 'EvaluationAppraisals', 'action' => 'index', $evaluacion['EvaluationAppraisal']['property_id']), array('update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false));
?>
<br>        
